package com.code.day19;

import java.util.Comparator;
import java.util.TreeMap;


public class Demo07TreeMap {
    public static void main(String[] args) {
        TreeMap<String,String> map1 = new TreeMap();
        map1.put("a","锄禾日当午");
        map1.put("c","谁知盘中餐");
        map1.put("d","粒粒皆辛苦");
        map1.put("b","汗滴禾下土");
        System.out.println(map1);

        TreeMap<Person,String> map2 = new TreeMap(new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getAge()-o2.getAge();
            }
        });
        map2.put(new Person("小王",18),"小王18岁");
        map2.put(new Person("小张",19),"小张19岁");
        map2.put(new Person("小李",20),"小李20岁");
        System.out.println(map2);

    }
}
